package com.example.videoproject.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.videoproject.pojo.Unite;
import com.example.videoproject.pojo.Unite2;
import com.example.videoproject.pojo.Videolike;
import com.example.videoproject.service.IVideolikeService;
import com.example.videoproject.utils.Code;
import com.example.videoproject.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Stream;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 二组
 * @since 2022-07-23
 */
@RestController
@RequestMapping("/videolike")
public class VideolikeController {

    @Autowired
    private IVideolikeService videoLikeService;

    //查询收藏视频
    @PostMapping("getCollections")
    public Result getCollections(Integer uid,String search){
        List<Unite2> list = videoLikeService.select(uid);

        List<Unite2> uniteList=new ArrayList<>();

        if (search.trim().length()!=0){
            list.forEach(temp->{
                if (temp.getVtitle().contains(search)){
                    uniteList.add(temp);
                }
            });
            return new Result(Code.SELECT_OK,uniteList);
        }else {
            return new Result(Code.SELECT_OK,list);
        }
    }


}

